﻿using System;

namespace Spencen.Mobile.Markup.Extensions
{
    public class BindingMarkupExtension : IMarkupExtension
    {
        #region IMarkupExtension Members

        public string ExtensionName { get { return "Binding"; } }

        public object Resolve( XamlNode context, Type expectedType, string args )
        {
            if ( !this.HasNamedProperties( args ) )
                return new Binding( ( (XamlElement)context ).Type, args );
            else
            {
                var binding = new Binding( ( (XamlElement)context ).Type );
                this.ResolveArgsToProperties( binding, args );
                return binding;
            }
        }

        #endregion
    }
}
